﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Imagenator.Forms
{
	partial class SettingsForm : ArgusLib.Controls.BaseForm
	{
		public SettingsForm(int minHeight)
		{
			InitializeComponent();
			this.nudThumbnailHeight.Minimum = new decimal(minHeight);
			Settings settings = Settings.Load<Settings>();
			this.cbShowPrevImages.Checked = settings.ShowPreviewImages;
			//this.nudThumbnailWidth.Value = new decimal(settings.PreviewImageHeight);
			this.nudThumbnailWidth.Value = new decimal(settings.ThumbnailSize.Width);
			this.nudThumbnailHeight.Value = new decimal(settings.ThumbnailSize.Height);
			this.cbCheckUpdates.Checked = settings.CheckForUpdates;
		}

		private void cbShowPrevImages_CheckedChanged(object sender, EventArgs e)
		{
			this.pThumbnailSize.Enabled = this.cbShowPrevImages.Checked;
		}

		protected override void OnFormClosing(FormClosingEventArgs e)
		{
			Settings settings = Settings.Load<Settings>();
			settings.ShowPreviewImages = this.cbShowPrevImages.Checked;
			//settings.PreviewImageHeight = (int)this.nudThumbnailWidth.Value;
			settings.ThumbnailSize = new System.Drawing.Size((int)this.nudThumbnailWidth.Value, (int)this.nudThumbnailHeight.Value);
			settings.CheckForUpdates = this.cbCheckUpdates.Checked;
			settings.Save();
			base.OnFormClosing(e);
		}

		private void button1_Click(object sender, EventArgs e)
		{
			Settings settings = Settings.Load<Settings>();
			settings.Reset();
			this.cbShowPrevImages.Checked = settings.ShowPreviewImages;
			this.nudThumbnailWidth.Value = new decimal(settings.ThumbnailSize.Width);
			this.nudThumbnailHeight.Value = new decimal(settings.ThumbnailSize.Height);
			this.cbCheckUpdates.Checked = settings.CheckForUpdates;
		}
	}
}
